package cn.hinglo.gameclaw.data.config;

import cn.hinglo.gameclaw.data.interceptors.ClientUserIdInterceptors;
import cn.hinglo.gameclaw.data.interceptors.LoginInterceptors;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @createTime: 2018/1/4
 * @author: HingLo
 * @description: 全局配置文件处理
 */
@Configuration
public class WebConfiguration implements WebMvcConfigurer {

    /**
     * 全局拦截器处理配置
     *
     * @param interceptorRegistry 拦截器对象
     */
    @Override
    public void addInterceptors(InterceptorRegistry interceptorRegistry) {
        //添加拦截器
        interceptorRegistry.addInterceptor(new LoginInterceptors()).addPathPatterns("/admin/**", "/im/**", "/user/i/**");
        //客户端拦截器
        interceptorRegistry.addInterceptor(new ClientUserIdInterceptors())
                .addPathPatterns("/client/**", "/pay/r/money", "/pay/l/**")
                //排除异步支付通知的请求链接
                .excludePathPatterns("/pay/l/moneyNotifyAlipay", "/pay/l/moneyNotifyWeixin");
    }
}
